﻿using System;
using System.Text;

public enum EngineType
{
    Petrol = 1,
    Diesel = 2, 
    Hybrid = 3, 
    Electric = 4
}

public struct Engine
{
    //fields
    private EngineType type;
    private float capacity;
    private int horsePower;
    private int mileage;
    private double expense;

    //constructors



    public Engine(EngineType type, float capacity, int horsePower, double expense, int mileage)
        : this()
    {
        this.Type = type;
        this.Capacity = capacity;
        this.HorsePower = horsePower;
        this.Expense = expense;
        this.Mileage = mileage;
    }

    //properties
    public EngineType Type
    {
        get { return this.type; }
        set { this.type = value; }
    }

    public float Capacity
    {
        get { return this.capacity; }
        set { this.capacity = value; }
    }
    public int HorsePower
    {
        get { return this.horsePower; }
        set { this.horsePower = value; }
    }
    public double Expense
    {
        get { return this.expense; }
        set { this.expense = value; }
    }

    public int Mileage
    {
        get { return this.mileage; }
        set
        {
            if (value >= 0)
            {
                this.mileage = value;
            }
            else
            {
                throw new ArgumentException("Invalid mileage entered.");
            }
        }
    }



    //methods
    public override string ToString()
    {
        StringBuilder engineText = new StringBuilder();
        engineText.AppendLine("Engine type: " + this.type.ToString());
        engineText.AppendLine("Engine capacity: " + this.capacity.ToString());
        engineText.AppendLine("Horse power: " + this.horsePower.ToString());
        engineText.AppendLine("Mileage: " + this.mileage.ToString());
        engineText.AppendLine("Expense: " + this.expense.ToString() + " litres per 100 km");
        return engineText.ToString();
    }
}
